import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: '',
    username: '',
    password: '',
    salt: ''
  },
  mutations: {
    dataInput(state, payload) {
      state.token = payload.token
      state.username = payload.username
      state.password = payload.password
    },
    cleanState(state) {
      // 清除所有状态
      state.token = ''
      state.username = ''
      state.password = ''
    }
  },
  actions: {
    dataInput(context, params) {
      context.commit('dataInput', params)
    },
    cleanState(context) {
      context.commit('cleanState')
    }
  },
  modules: {
  }
})
